package com.chase.springboot.service.impl;

import com.chase.springboot.mapper.MenuMapper;
import com.chase.springboot.mapper.RoleMenuMapper;
import com.chase.springboot.model.Menu;
import com.chase.springboot.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MenuServiceImpl implements MenuService {
    @Autowired
    private MenuMapper menuMapper;
    @Autowired
    private RoleMenuMapper roleMenuMapper;

    @Override
    public boolean add(Menu menu) {
        int i = menuMapper.insert(menu);
        return i > 0;
    }

    @Override
    public boolean deleteById(int id) {
        //删除角色关联
        int i2 = roleMenuMapper.deleteByMenuId(id);
        //删除菜单
        int i = menuMapper.deleteByPrimaryKey(id);
        return i2 > 0 && i > 0;
    }
}
